<template>
    <el-dialog
        title="设备属性设置"
        :visible.sync="dialogVisible"
        width="30%"
    		:close-on-click-modal="false">
        <el-form
            label-width="95px"
            ref="equipExtend"
            :model="equipExtend"
        >
            <el-form-item label="属性名称:" prop="name">
                <el-input v-model="this.var.names" disabled></el-input>
            </el-form-item>
            <el-form-item label="属性说明:" prop="name">
                <el-input v-model="this.var.describes" disabled></el-input>
            </el-form-item>
            <el-form-item label="属性值:" prop="name">
                <el-input v-show="this.var.componentType === 5 || this.var.componentType === 4 " v-model="equipExtend.varValue"></el-input>

                <el-select clearable
                    v-show="this.var.componentType === 3"
                    v-model="equipExtend.varValue"
                    placeholder="请填写属性值"
                >
                    <el-option
                        v-for="item in $dictUtils.getDictList(this.var.dictCode)"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                    ></el-option>
                </el-select>
            </el-form-item>
        </el-form>

        <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="doSubmit()">确 定</el-button>
  </span>
    </el-dialog>
</template>

<script>
export default {
    data () {
        return {
            dialogVisible: false,
            tableData: [],
            editForm: {

            },
            equipExtend: {
                outerCode: '', // 控制盒序号,
                equipId: '',
                equipInnerCode: '',
                varSn: '',
                varValue: ''
            },
            var: {
                id: '',
                names: '',
                describes: '',
                componentType: '',
                dictCode: ''
            }
        }
    },
   methods: {
       handleClose (done) {
           this.$Msg.confirm({
               title: '您确定要关闭吗？',
               content: this.GLOBAL.FORM_CLOSE_TIPS,
               confirmCall: () => {
                   done()
               }
           })
       },
       init (row, form) {
           this.var = row
           this.dialogVisible = true
           this.equipExtend = form
           console.log(this.var)
           this.equipExtend.varSn = row.id
       },
       // 表单提交
       doSubmit () {
           console.log(this.equipExtend)
           this.$refs['equipExtend'].validate((valid) => {
               if (valid) {
                   this.loading = true
                   this.$http({
                       url: `/equip/equipExtend/save`,
                       method: 'post',
                       headers: {'Content-Type': 'application/json; charset=utf-8'},
                       data: this.equipExtend
                   }).then(({data}) => {
                       if (data && data.code === '200') {
                           this.visible = false
                           this.$message.success(data.message)
                           this.$emit('refreshDataList')
                       }
                   })
               }
           })
       }
   }
}
</script>

<style scoped>

</style>
